$(function () {
    resetui()
    $("#btnSend").on("click", function () {
        const text = $('#ipt').val().trim();
        if (text.length <= 0) {
            $('#ipt').val('')
            return
        }
        var htmls = ` <li class="right_word">
        <img src="img/person02.png" /> <span>${text}</span>
      </li>`
        $('.talk_list').append(htmls);
        $('#ipt').val('')
        resetui()
        getBosta(text)
    })
    function getBosta(mges) {
        $.ajax({
            method: 'GET',
            data: {
                spoken: mges
            },
            url: 'http://www.liulongbin.top:3006/api/robot',
            success: function (res) {
                // console.log(res);
                if (res.message === 'success') {
                    var msg = res.data.info.text
                    console.log(msg);
                    var httlas = `<li class="left_word"><img src="img/person01.png" /> <span>${msg}</span></li>`
                    $('#talk_list').append(httlas);
                    resetui()
                    getvideo(msg)
                }
            }
        })
    }
    function getvideo(text) {
        $.ajax({
            method: 'GET',
            url: 'http://www.liulongbin.top:3006/api/synthesize',
            data: {
                text: textekk
            },
            success: function (res) {
                console.log(res);
                if (res.status === 200) {
                    $('#voice').arrt('src', res.voiceUrl)
                }
            }
        })
    }
})